package com.lj.job.param;

import com.lj.job.entity.ScheduleJob;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

/**
 * <p>
 * 定时任务 保存参数
 * </p>
 *
 * @author luojing
 * @since 2025-03-20 15:23:28
 */
@Data
@Schema(description = "定时任务 保存参数")
public class JobSaveParam {

    @Schema(description = "执行bean的名称")
    @NotBlank(message = "执行bean的名称 不能为空")
    private String beanName;

    @Schema(description = "执行参数")
    private String params;

    @Schema(description = "cron表达式")
    @NotBlank(message = "cron表达式 不能为空")
    private String cronExpression;

    @Schema(description = "备注")
    private String remark;

    public ScheduleJob toEntity() {
        ScheduleJob entity = new ScheduleJob();
        entity.setBeanName(beanName);
        entity.setParams(params);
        entity.setCronExpression(cronExpression);
        entity.setRemark(remark);
        return entity;
    }
}
